using System.Web.UI;
using System.Web.UI.HtmlControls;

namespace FluentTags
{

    public class ITag : Tag<ITag>
    {
        public ITag() : base("i"){}
        
        public ITag(string text) : this()
        {
            Controls.Add(new LiteralControl(text));
        }

        public ITag(object value) : this()
        {
            Controls.Add(new LiteralControl(SafeString(value)));
        }
        
        
        public ITag(Control control) : this()
        {
            Controls.Add(control);
        }
        
        
        
        
        public ATag<ITag> A()
        {
            var ctrl = new ATag<ITag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ITag A(ATag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public ATag<ITag> A(string text)
        {
            var ctrl = new ATag<ITag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public ATag<ITag> A(Control control)
        {
            var ctrl = new ATag<ITag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public ATag<ITag> A(object value)
        {
            return A(SafeString(value));
        }
        
        public BTag<ITag> B()
        {
            var ctrl = new BTag<ITag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ITag B(BTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public BTag<ITag> B(string text)
        {
            var ctrl = new BTag<ITag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public BTag<ITag> B(Control control)
        {
            var ctrl = new BTag<ITag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public BTag<ITag> B(object value)
        {
            return B(SafeString(value));
        }
        
        public BRTag<ITag> BR()
        {
            var ctrl = new BRTag<ITag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ITag BR(BRTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public EMTag<ITag> EM()
        {
            var ctrl = new EMTag<ITag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ITag EM(EMTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public EMTag<ITag> EM(string text)
        {
            var ctrl = new EMTag<ITag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public EMTag<ITag> EM(Control control)
        {
            var ctrl = new EMTag<ITag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public EMTag<ITag> EM(object value)
        {
            return EM(SafeString(value));
        }
        
        public ITag<ITag> I()
        {
            var ctrl = new ITag<ITag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ITag I(ITag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public ITag<ITag> I(string text)
        {
            var ctrl = new ITag<ITag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public ITag<ITag> I(Control control)
        {
            var ctrl = new ITag<ITag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public ITag<ITag> I(object value)
        {
            return I(SafeString(value));
        }
        
        public ImgTag<ITag> Img()
        {
            var ctrl = new ImgTag<ITag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ITag Img(ImgTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public SpanTag<ITag> Span()
        {
            var ctrl = new SpanTag<ITag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ITag Span(SpanTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public SpanTag<ITag> Span(string text)
        {
            var ctrl = new SpanTag<ITag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public SpanTag<ITag> Span(Control control)
        {
            var ctrl = new SpanTag<ITag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public SpanTag<ITag> Span(object value)
        {
            return Span(SafeString(value));
        }
        
        public StrongTag<ITag> Strong()
        {
            var ctrl = new StrongTag<ITag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ITag Strong(StrongTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public StrongTag<ITag> Strong(string text)
        {
            var ctrl = new StrongTag<ITag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public StrongTag<ITag> Strong(Control control)
        {
            var ctrl = new StrongTag<ITag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public StrongTag<ITag> Strong(object value)
        {
            return Strong(SafeString(value));
        }
        
        public SubTag<ITag> Sub()
        {
            var ctrl = new SubTag<ITag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ITag Sub(SubTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public SubTag<ITag> Sub(string text)
        {
            var ctrl = new SubTag<ITag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public SubTag<ITag> Sub(Control control)
        {
            var ctrl = new SubTag<ITag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public SubTag<ITag> Sub(object value)
        {
            return Sub(SafeString(value));
        }
        
        public SupTag<ITag> Sup()
        {
            var ctrl = new SupTag<ITag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ITag Sup(SupTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public SupTag<ITag> Sup(string text)
        {
            var ctrl = new SupTag<ITag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public SupTag<ITag> Sup(Control control)
        {
            var ctrl = new SupTag<ITag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public SupTag<ITag> Sup(object value)
        {
            return Sup(SafeString(value));
        }
        
        
        public ITag Text(string text)
        {
            Controls.Add(new LiteralControl(text));
            return this;
        }

        public ITag Text(object value)
        {
            Controls.Add(new LiteralControl(SafeString(value)));
            return this;
        }
        
    }

    public class ITag<ParentType> : ChildTag<ITag<ParentType>, ParentType>
        where ParentType : HtmlGenericControl
    {
        public ITag(ParentType parent) : base("i", parent) { }

        
        
        
        public ATag<ITag<ParentType>> A()
        {
            var ctrl = new ATag<ITag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ITag<ParentType> A(ATag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public ATag<ITag<ParentType>> A(string text)
        {
            var ctrl = new ATag<ITag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public ATag<ITag<ParentType>> A(Control control)
        {
            var ctrl = new ATag<ITag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public ATag<ITag<ParentType>> A(object value)
        {
            var ctrl = new ATag<ITag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public BTag<ITag<ParentType>> B()
        {
            var ctrl = new BTag<ITag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ITag<ParentType> B(BTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public BTag<ITag<ParentType>> B(string text)
        {
            var ctrl = new BTag<ITag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public BTag<ITag<ParentType>> B(Control control)
        {
            var ctrl = new BTag<ITag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public BTag<ITag<ParentType>> B(object value)
        {
            var ctrl = new BTag<ITag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public BRTag<ITag<ParentType>> BR()
        {
            var ctrl = new BRTag<ITag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ITag<ParentType> BR(BRTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public EMTag<ITag<ParentType>> EM()
        {
            var ctrl = new EMTag<ITag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ITag<ParentType> EM(EMTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public EMTag<ITag<ParentType>> EM(string text)
        {
            var ctrl = new EMTag<ITag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public EMTag<ITag<ParentType>> EM(Control control)
        {
            var ctrl = new EMTag<ITag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public EMTag<ITag<ParentType>> EM(object value)
        {
            var ctrl = new EMTag<ITag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public ITag<ITag<ParentType>> I()
        {
            var ctrl = new ITag<ITag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ITag<ParentType> I(ITag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public ITag<ITag<ParentType>> I(string text)
        {
            var ctrl = new ITag<ITag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public ITag<ITag<ParentType>> I(Control control)
        {
            var ctrl = new ITag<ITag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public ITag<ITag<ParentType>> I(object value)
        {
            var ctrl = new ITag<ITag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public ImgTag<ITag<ParentType>> Img()
        {
            var ctrl = new ImgTag<ITag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ITag<ParentType> Img(ImgTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public SpanTag<ITag<ParentType>> Span()
        {
            var ctrl = new SpanTag<ITag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ITag<ParentType> Span(SpanTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public SpanTag<ITag<ParentType>> Span(string text)
        {
            var ctrl = new SpanTag<ITag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public SpanTag<ITag<ParentType>> Span(Control control)
        {
            var ctrl = new SpanTag<ITag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public SpanTag<ITag<ParentType>> Span(object value)
        {
            var ctrl = new SpanTag<ITag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public StrongTag<ITag<ParentType>> Strong()
        {
            var ctrl = new StrongTag<ITag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ITag<ParentType> Strong(StrongTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public StrongTag<ITag<ParentType>> Strong(string text)
        {
            var ctrl = new StrongTag<ITag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public StrongTag<ITag<ParentType>> Strong(Control control)
        {
            var ctrl = new StrongTag<ITag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public StrongTag<ITag<ParentType>> Strong(object value)
        {
            var ctrl = new StrongTag<ITag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public SubTag<ITag<ParentType>> Sub()
        {
            var ctrl = new SubTag<ITag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ITag<ParentType> Sub(SubTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public SubTag<ITag<ParentType>> Sub(string text)
        {
            var ctrl = new SubTag<ITag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public SubTag<ITag<ParentType>> Sub(Control control)
        {
            var ctrl = new SubTag<ITag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public SubTag<ITag<ParentType>> Sub(object value)
        {
            var ctrl = new SubTag<ITag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        public SupTag<ITag<ParentType>> Sup()
        {
            var ctrl = new SupTag<ITag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public ITag<ParentType> Sup(SupTag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public SupTag<ITag<ParentType>> Sup(string text)
        {
            var ctrl = new SupTag<ITag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public SupTag<ITag<ParentType>> Sup(Control control)
        {
            var ctrl = new SupTag<ITag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public SupTag<ITag<ParentType>> Sup(object value)
        {
            var ctrl = new SupTag<ITag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        
        public ITag<ParentType> Text(string text)
        {
            Controls.Add(new LiteralControl(text));
            return this;
        }
        
        public ITag<ParentType> Text(object value)
        {
            Controls.Add(new LiteralControl(SafeString(value)));
            return this;
        }
        
        
    }
}